import model from './model'
import MixinsList from '@screen/mixins/initList'
import API from '../API/list.js'
API.getList = API.getRealList
export default {
  /**
   * 混入（列表）
   */
  mixins: [MixinsList],
  data() {
    return {
      API: API,
      model: model(),
      handlerList: [],
      defaultImg: require('../../../assets/img/alarm/alarm-icon.png'),
    }
  },
  watch: {
    list: {
      handler(newVal) {
        this.handlerList = newVal.map(item => {
          let fileUrl = this.defaultImg
          if (item.messageAlarmFileDto.length) {
            const obj = item.messageAlarmFileDto.find(ele => ele.fileType === 1) || {}
            fileUrl = obj.fileUrl
          }
          item.fileUrl = fileUrl
          return item
        })
      },
      deep: true,
    },
  },
  methods: {
    toMore() {
      this.$router.push({ name: 'AlarmMore' })
    },
  },
  created() {
  },
}
